<?php
	session_start();
	require("connect.php");
	$link = connect_APO();
	
	require("check.php");
	is_admin();
	
	require("header+logoutB.php");
	headerL();
	
	$midweekName=$_GET['midweek'];
	$remove=$_POST['removeM'];
	
	echo "<html>
<body class='main'>

<FONT class='mainFont'>
		<CENTER>
	    <!--<p><img src = 'images/apopic.jpg'></p>-->
	    <br>
		<br>
		<div class='headerTable'>
			
			<b class='b1f'></b><b class='b2f'></b><b class='b3f'></b><b class='b4f'></b>";
	
	if (strcmp($remove, "no")==0){
		echo "<div class='contentf'>The midweek has not been removed.</div>";	
	} else {
		$sql = sprintF("DROP Table $midweekName");
		$result = mysql_query($sql);
		$sqlInt = sprintF("SELECT * From `midweeks` WHERE Name='$midweekName'");
		$resultInt = mysql_query($sqlInt);
		$row = mysql_fetch_array($resultInt);
		$leader1 = $row["Leader1"];
		$leader2= $row["Leader2"];
		$sqlInt = sprintF("UPDATE `users` SET `ML` = '0' WHERE `users`.`ID` = '$leader1'");
		$resultInt = mysql_query($sqlInt);
		$sqlInt = sprintF("UPDATE 'users` SET `ML` = '0' WHERE `users`.`ID` = '$leader2'");
		$resultInt = mysql_query($sqlInt);
		$sql2 = sprintF("DELETE FROM `midweeks` WHERE Name='$midweekName' LIMIT 1");
		$result2 = mysql_query($sql2);
		echo "<div class='contentf'>The midweek has been dropped.</div>";
	}
	echo "<b class='b4f'></b><b class='b3f'></b><b class='b2f'></b><b class='b1f'></b>
		</div>
	</center>
</font>
</body>
</head>
</html>";